package com.alex.goods.service.impl;

import com.alex.goods.dao.OrdersDao;
import com.alex.goods.entity.GoodsOrders;
import com.alex.goods.entity.InOutSum;
import com.alex.goods.service.OrdersService;
import com.alex.goods.util.TimeUtil;

import java.time.LocalDateTime;
import java.util.List;

public class OrdersServiceImpl implements OrdersService{

	private OrdersDao orderDao = new OrdersDao();
	
	
	
	@Override
	public List<GoodsOrders> selectOrdersList(String sql,Integer page,Integer limit) {
		
	    return  orderDao.selectOrdersList(sql,page,limit);
	    
	}
	@Override
	public void addOrder(String goodsNo, String factory, String singlePrice, Integer num, String unit,
			String dateio,
			String personName, String tel, String status) {
		String datetime = TimeUtil.makeTimeString(LocalDateTime.now());
		
		String orderNo = "" + datetime + goodsNo;
		
		
		
		
		orderDao.addOrder(orderNo,goodsNo,factory,singlePrice,num, datetime,unit,dateio,personName,tel,status);
	}
    
	
	
	@Override
	public Long getOrdersNum(String sql) {
		// TODO Auto-generated method stub
	  return orderDao.getOrdersNum(sql);
	}
	
	@Override
	public Long getInOutNum(String sql) {
	
		return orderDao.getInOutNum(sql); 
	}
	@Override
	public List<InOutSum> selectSumList(String sqlfrom, Integer page, Integer limit) {
		// TODO Auto-generated method stub
		return orderDao.selectSumList(sqlfrom,page,limit);
	}
	@Override
	public List<InOutSum> selectSumByGoodsNo(String goodsNo, String start, String end,String status1,String status2) {
		// TODO Auto-generated method stub

		return orderDao.selectSumByGoodsNo(goodsNo,start,end,status1,status2);
	}
	
	@Override
	public void updateOrder(String goodsNo,String orderNo ,String factory, String singlePrice, Integer num,
			String dateio, String unit,
			String personName, String tel, String statusx) {
		// TODO Auto-generated method stub
		orderDao.updateOrder(goodsNo,  orderNo, factory, singlePrice, num, dateio, unit, personName, tel, statusx);
	}

	@Override
	public void deleteOrderByOrderNo(String orderNo, String goodsNo) {
		// TODO Auto-generated method stub
		orderDao.deleteOrderByOrderNo(orderNo,goodsNo);
	}

}
